package com.socialcoco.serviceImpl;

import com.alibaba.fastjson.JSON;
import com.socialcoco.service.elasticSearchService;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.xcontent.XContentType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;

@Service
public class elasticSearchServiceImpl implements elasticSearchService {
    @Autowired
    private RestHighLevelClient restHighLevelClient;

    //同步数据库的删除
    @Override
    public void delete(int id) {


    }
    //同步数据库中的增加修改
    @Override
    public void insertUpdate(int id) {
//        try{
//            IndexRequest indexRequest = new IndexRequest("diaryrespones").source(JSON.toJSONString(diaryRespone), XContentType.JSON);
//            restHighLevelClient.index(indexRequest, RequestOptions.DEFAULT);
//        }catch (IOException e){
//            throw  new RuntimeException(e);
//        }
    }
}
